package myschool.test2;

import myschool.dao.StudentDao;
import myschool.entity.Student;
import myschool.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.cache.impl.PerpetualCache;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class Cache2 {
    public static void main(String[] args) {
        List<Student> s1 = p1();
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>");
       // del(212L);
        List<Student> s2 = p1();
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        System.out.println(s1==s2);//redis

    }
    public static void del(long id){
        SqlSession s= MybatisUtil.get();
        StudentDao mapper = s.getMapper(StudentDao.class);
        int d = mapper.del(id);
        System.out.println(d);
        s.commit();
        MybatisUtil.close(s);
    }
    public static List<Student> p1(){
        SqlSession s= MybatisUtil.get();
        StudentDao mapper = s.getMapper(StudentDao.class);
        List<Student> l1 = mapper.paging(1, 20);
        System.out.println(l1);
        MybatisUtil.close(s);
        return l1;
    }
}
